计算最小二乘线性回归 - 知识点总结
最小二乘法是一种数学优化技术,通过最小化误差的平方和来寻找数据的最佳函数匹配。
The least squares method is a mathematical optimization technique that finds the best function match for the data by minimizing the sum of the squares of the errors.
目标函数 / Objective Function:最小化残差平方和 Minimize the sum of squared residuals
\[S = \sum_{i=1}^{n} (y_i - \hat{y}_i)^2\]
回归直线是对自变量和因变量之间线性关系的数学描述,其形式为:
The regression line is a mathematical description of the linear relationship between the independent variable and the dependent variable, with the form:
\[\hat{y} = a + bx\]
其中,\(a\) 是截距(intercept),\(b\) 是斜率(slope)。
Where \(a\) is the intercept and \(b\) is the slope.
| 步骤 / Step | 计算内容 / Calculation Content | 结果 / Result |
|---|---|---|
| 1 | 样本量 \(n\) | \(n = 5\) |
| 2 | \(\sum x_i\) | 25 |
| \(\sum y_i\) | 116 | |
| \(\sum x_i^2\) | 151 | |
| \(\sum y_i^2\) | 2928 | |
| \(\sum x_i y_i\) | 658 | |
| 3 | \(\bar{x} = \frac{25}{5}\) | 5 |
| \(\bar{y} = \frac{116}{5}\) | 23.2 | |
| 4 | \(S_{xx} = 151 - \frac{25^2}{5}\) | 26 |
| 5 | \(S_{xy} = 658 - \frac{25 \times 116}{5}\) | 78 |
| 6 | \(b = \frac{78}{26}\) | 3 |
| 7 | \(a = 23.2 - 3 \times 5\) | 8.2 |
| 8 | 回归方程 / Regression Equation | \(\hat{y} = 8.2 + 3x\) |